﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Model.WXshopBuiness;
using Model.WeiXin;
using Xproject.Util;

namespace WeiXinProject.Controllers
{
    public class WXBaseController : CommonBaseController
    {
        
        public ZXUserInfoModel CurrentUser {
            get
            {
               
                if (this.GetSession() != null)
                {
                    ZXUserInfoModel u  = this.GetSession() as ZXUserInfoModel;
                    return u;
                }
                return null;
            }
        }

        public string zxUserId {
            get;
            set;
        }

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {            
            GoToLogin();
            base.OnActionExecuting(filterContext);
        }


        private void GoToLogin()
        {
           // LogHelper.WriteInfoLog("来过这里：" + Request.RawUrl);
            if (CommonHelper.GetAppSettings("DESIGN_DEBUGGER")=="0") {
             //   LogHelper.WriteInfoLog("这里也来过：" );
               if (this.CurrentUser == null)
                {
                   // LogHelper.WriteInfoLog("这里也来过3333：");
                    string url = Request.RawUrl;
                    url = HttpUtility.UrlEncode(url);

                  //  LogHelper.WriteInfoLog("原来网址是："+url);
                    Response.Redirect("~/Login/Index?gotoUrl="+url);
                }
            }
            
            
        }
    }
}